{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c0043c81",
   "metadata": {},
   "source": [
    "# 1. 用“def\"命名代码块"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "45d8c641",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 给定一个单词，它会输出这个单词中包含的元音\n",
    "vowels = set('aeiou')\n",
    "word = input(\"Provide a word to search for vowels: \")\n",
    "found = vowels.intersection(set(word))\n",
    "for vowel in found:\n",
    "    print(vowel)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "82bf4cde",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 用def关键字创建函数\n",
    ">>> def search4vowels()\n",
    "vowels = set('aeiou')\n",
    "word = input(\"Provide a word to search for vowels: \")\n",
    "found = vowels.intersection(set(word))\n",
    "for vowels in found:\n",
    "    print(vowel)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1649c9ee",
   "metadata": {},
   "source": [
    "# 2.调用创建好的函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "984388cd",
   "metadata": {},
   "outputs": [],
   "source": [
    ">>> search4vowels \n",
    "Provide a word to search for vowels: hitch-hiker"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7f35f22e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 再次调用函数\n",
    ">>> search4vowels \n",
    "Provide a word to search for vowels: galaxy"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c99011b1",
   "metadata": {},
   "source": [
    "# 3. 用IDLE编辑器修改"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6dbef7e1",
   "metadata": {},
   "outputs": [],
   "source": [
    "def search4vowels():\n",
    "    vowels = set('aeiou')\n",
    "    word = input(\"Provide a word to search for vowels: \")\n",
    "    found = vowels.intersection(set(word))\n",
    "    for vowel in found:\n",
    "        print(vowel)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6df7b84e",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 增加动词string\n",
    "def search4vowels():\n",
    "    \"\"\"Display any vowels found in an asked-found word\"\"\"\n",
    "    vowels = set('aeiou')\n",
    "    word = input(\"Provide a word to search for vowels: \")\n",
    "    found = vowels.intersection(set(word))\n",
    "    for vowel in found:\n",
    "        print(vowel)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5667adf2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b4bf9add",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7022f75e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
